/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

import entity.Menu;
import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Windows7
 */
public class TableMenu extends AbstractTableModel {

    public static ArrayList<Menu> menu;
    private final String columnName[] = {"Menu_Id", "Menu", "MenuItem", "Menu_price"};
    private final Class columnClass[] = {Integer.class, String.class, String.class, Float.class};

    public TableMenu(ArrayList<Menu> menu) {
        this.menu = menu;
    }

    public TableMenu() {
        menu = new ArrayList<Menu>();
    }

    public int getRowCount() {
        return this.menu.toArray().length;
    }

    public int getColumnCount() {
        return columnName.length;
    }

    @Override
    public String getColumnName(int column) {
        return columnName[column];
    }

    public Object getValueAt(int rowIndex, int columnIndex) {
        switch (columnIndex) {
            case 1:
                return menu.get(rowIndex).getMenu_Id();
            case 2:
                return menu.get(rowIndex).getMenu();
            case 3:
                return menu.get(rowIndex).getMenu_Id();
            case 4:
                return menu.get(rowIndex).getMenu_Price();
            default:
                return null;
        }
    }
}
